<template>
    <rx-layout>
        <div slot="center" style>
            <rx-fit>
                <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
                    <div class="table-operator">
                        <rx-button alias="sysKettleLogDelete" v-if="removeEnable && selectedRowKeys.length > 0"
                                   :butn-icon="'delete'" :butn-type="'danger'" :show-no-right="true"
                                   @click="delByIds(selectedRowKeys)">{{$ti18('rxList.delBtn','删除')}}
                        </rx-button>
                    </div>
                    <span class="search-btn-box">
                <span class="search-btn" @click="searchshow"><i class="iconfont iconguolv"></i>{{$ti18('rxList.leachBtn','过滤')}}</span>
           </span>
                </div>
                <div slot="searchbar" btnalign="right" v-if="fitSearch" @search="search" @cancel="cancel"
                     @close="close">
                    <a-form layout="vertical">
                        <a-form-item :label="i18n('form.status','状态')">
                            <a-select :placeholder="i18n('form.status','状态','select')" v-model="queryParam['Q_STATUS__I_EQ']"
                                      :allowClear="true">
                                <a-select-option :value="1">{{i18n('form.success','成功')}}</a-select-option>
                                <a-select-option :value="0">{{i18n('form.failure','失败')}}</a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-form>
                </div>
                <rx-grid
                    ref="table"
                    :allowRowSelect="true"
                    :multiSelect="true"
                    :columns="columns"
                    :defaultPageSize="10"
                    url="/api-system/system/core/sysKettleLog/query"
                    :queryParam="queryParam"
                    data-field="result.data"
                    :pageSizeOptions="['10','30','40']"
                    id-field="id"
                    @selectChange="onSelectChange"
                >
                    <span slot="kettleType" slot-scope="{ text, record }">
                        <span>{{ typeMap[text] }}</span>
                    </span>
                    <span slot="status" slot-scope="{ text, record }">
                       <a-tag :color="statusMap[text].color">
                            <span>{{ statusMap[text].text }}</span>
                        </a-tag>
                    </span>
                    <span slot="action" slot-scope="{ text, record }" class="actionIcons">
                        <span @click="edit(record)">{{i18n('list.view','查看')}}</span>
                        <span v-if="removeEnable && showBtn(false)" @click="delByIds([record.id])">{{$ti18('rxList.delBtn','删除')}}</span>
                    </span>
                </rx-grid>
            </rx-fit>
        </div>
    </rx-layout>
</template>

<script>
import SysKettleLogApi from '@/api/system/core/sysKettleLog'
import SysKettleLogEdit from './SysKettleLogEdit'
import {BaseList, RxFit, RxGrid} from "@lowcode/jpaas-common-lib";

export default {
    name: 'SysKettleLogList',
    mixins: [BaseList],
    components: {
        RxFit
    },
    data() {
        return {
            columns: [
                {
                    title: this.$ti18('rxList.index','序号'),
                    type: 'indexColumn',
                    width: 60,
                    dataIndex: 'serial',
                    scopedSlots: {customRender: 'serial'}
                },
                {title: this.i18n('form.kettleJob','KETTLE任务'), dataIndex: 'kettleJobName', width: 100},
                {title: this.i18n('form.duration','运行时长(毫秒)'), dataIndex: 'druation', width: 100},
                {title: this.i18n('form.type','类型'), dataIndex: 'kettleType', width: 100, scopedSlots: {customRender: 'kettleType'}},
                {title: this.i18n('form.status','状态'), dataIndex: 'status', width: 100, scopedSlots: {customRender: 'status'}},
                {title: this.$ti18('rxList.action','操作'), width: 100, dataIndex: 'action', scopedSlots: {customRender: 'action'}}
            ],
            component: SysKettleLogEdit,
            comment: this.i18n('list.comment','KETTLE日志'),
            max: true,
            fitSearch: false,
            typeMap: {'job': this.i18n('form.job','作业'), 'transformation': this.i18n('form.transformation','转换')},
            statusMap: {
                '1': {color: 'green', text: this.i18n('form.success','成功')},
                '0': {color: 'blue', text: this.i18n('form.failure','失败')}
            }
        }
    },
    methods: {
        i18n(name,text,key){
            return this.$ti18(name,text,"SysKettleLog",key);
        },
        delById(ids) {
            return SysKettleLogApi.del({ids: ids.join(',')});
        },
        getListByParams(parameter) {
            return SysKettleLogApi.query(parameter)
        }
    }
}
</script>
<style scoped>

</style>

